<!-- 数据列表 -->
<div class="panel panel-default">
	<div style="margin-top: 2px;margin-bottom: 1px;">
		<input type="text" style="margin-left: 4px" id="words" value="<%=words%>" maxlength="8" placeholder="请输入姓名"
			   onkeypress="if(event.keyCode==13){$('#btnSearch').click();return false;}"/>
		<button class="btn btn-success" id="btnSearch">搜索</button>
		<button class="btn btn-primary" id="btnAdd">添加</button>
	</div>
	<% include person_list.ejs %>
</div>
<script>
	function list(page) {
		loadView('/person', {page: page, words: $('#words').val()});
	}
	function mdf(id) {
		loadView('/person/to/' + id, {page: '<%=page%>>', words: '<%=words%>'});
	}
	function del() {
		var id = $('#delID').val();
		if (id) {
			$.post('/person/del/' + id, function (data) {
				$('.modal-backdrop').remove();
				if (typeof data === 'string') {
					alert(data);
				} else {
					list('<%=data.rows.length==1?page-1:page%>');
				}
			});
		}
	}
	$(function () {
		$('[getVal]').each(function () {
			var ele = $(this);
			$.get('/wall/next/' + ele.attr('getVal'), function (val) {
				ele.html(val);
			})
		});
		$('#btnSearch').on('click', function () {
			list(1);
		});
		$('#btnAdd').on('click', function () {
			loadView('/person/to/0');
		});
	})
</script>
<!-- 删除确认 -->
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="dialog_del" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="dialog_del">询问提示</h4>
			</div>
			<div class="modal-body">确定删除“<span id="delName"></span>”?</div>
			<div class="modal-footer">
				<input type="hidden" id="delID" value="">
				<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="del()">确定</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>